package com.vhall.component.controller.interactive;

import com.vhall.component.controller.interactive.facade.DocumentUploadFacade;
import com.vhall.component.entity.interactive.vo.*;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.service.interactive.DocumentsUploadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Author: xin.qin
 * @Date: 2022/06/27 19:55
 */
@Slf4j
@VhallComponent
@TokenAuth
public class DocumentUploadController implements DocumentUploadFacade {

    @Autowired
    private DocumentsUploadService uploadService;

    @Override
    public UploadRegisterRespVO register(UploadRegisterReqVO reqVO) {
        return uploadService.register(reqVO.getFileMd5(), reqVO.getFileName(), reqVO.getFileSize(), reqVO.getMimetype(), reqVO.getFileExt());
    }

    @Override
    public UploadCheckChunkRespVO checkChunk(UploadCheckChunkReqVO reqVO) {
        return uploadService.checkChunk(reqVO.getFileMd5(), reqVO.getChunk(), reqVO.getChunkSize());
    }

    @Override
    public UploadChunkRespVO uploadChunk(UploadChunkReqVO reqVO) {
        return uploadService.uploadChunk(reqVO.getFile(), reqVO.getFileMd5(), reqVO.getChunk());
    }

    @Override
    public UploadMergeChunkRespVO mergeChunks(UploadMergeChunkReqVO reqVO) {
        return uploadService.mergeChunks(reqVO.getFileMd5(), reqVO.getFileName(), reqVO.getFileSize(), reqVO.getMimetype(), reqVO.getFileExt());
    }
}
